package study.bean;

public class Dog extends Animal {

   public String color;

  // public String name;


    public  Dog(){
        //条用父类的无参构造
        // super()  表示调用父类的构造函数
        super();
        System.out.println("Dog被创建了");
    }

     public Dog( String name,int age,String color){
         //调用父类两个参数的构造函数
        super(name,age);
        this.color=color;

     }


    public void watchDoor(){
       System.out.println("狗会看门");
   }

   public void print(){
       //访问父类的name的值
       //String testname = super.name;
       //System.out.println("testname=="+super.name);

       //System.out.println("打印"+this.name);
       System.out.println("打印"+super.age);

   }

    @Override
    public void eat() {
        super.eat();
        System.out.println("狗在吃东西");
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }
}
